SRCS = $(wildcard src/*.c)
OBJS = $(patsubst %.c,%.o,$(SRCS))
OBJS += src/startup_stm32f10x_hd.o

CC = arm-none-eabi-gcc
AR = arm-none-eabi-ar
AS = arm-none-eabi-as
CFLAGS= -c -mcpu=cortex-m3 -mthumb -O3 -D STM32F10X_HD -D USE_STDPERIPH_DRIVER -Iinc
SFLAGS= -c -mcpu=cortex-m3 -mthumb -D
libstm32f103zet6.a:$(OBJS)
	@printf "%-32s\033[32m==>\033[0m\t%-32s\n" [OBJS] $@
	@$(AR) rc $@ $^

%.o:%.s
	@printf "%-32s\033[31m==>\033[0m\t%-32s\n" $^ $@
	@$(AS) $(SFLAGS) $^ -o $@ 2> /dev/null

%.o:%.c
	@printf "%-32s\033[34m==>\033[0m\t%-32s\n" $^ $@
	@$(CC) $(CFLAGS) $^ -o $@
.PHONY:clean
clean:
	-@rm $(OBJS) 2>/dev/null
	-@rm libstm32f103zet6.a 2>/dev/null
